﻿
CREATE PROCEDURE [dbo].[proc_Finance_Outlay_Create]
	(
		@CreateDate datetime,
		@TradeDate nvarchar(10),
		@Summary nvarchar(50),
		@CateOneId int,
		@CateOneName nvarchar(50),
		@CateTwoId int,
		@CateTwoName nvarchar(50),
		@SubjectId int,
		@SubjectName nvarchar(50),
		@PaymentTypeId int,
		@PaymentTypeName nvarchar(50),
		@BankId int,
		@BankName nvarchar(50),
		@OutlayReason nvarchar(50),
		@OutlayPrice decimal(18,2),
		@Agent nvarchar(50),
		@AgentName nvarchar(50),
		@PZPerson nvarchar(50),
		@PZPersonName nvarchar(50),
		@SHPerson nvarchar(50),
		@SHPersonName nvarchar(50),
		@UserName nvarchar(50),
		@EName nvarchar(50),
		@Description nvarchar(4000),
		@BillNumber nvarchar(50),
		@CompanyId int,
		@CompanyIdCur int,
		@DepIdCur int,
		@deleteId int,
		@a_tx int
	)
AS
Begin
	--赋值单位编号，创建人员姓名
	--Select @CompanyId=CompanyId,@EName=EName From Employee Where UserName=@UserName
	Select @CompanyId=CompanyId, @EName=[Name] From aspnet_users Where UserName=@UserName
	Insert Into Finance_Outlay
	(
		CreateDate,
		TradeDate,
		Summary,
		CateOneId,
		CateOneName,
		CateTwoId,
		CateTwoName,
		SubjectId,
		SubjectName,
		PaymentTypeId,
		PaymentTypeName,
		BankId,
		BankName,
		OutlayReason,
		OutlayPrice,
		Agent,
		AgentName,
		PZPerson,
		PZPersonName,
		SHPerson,
		SHPersonName,
		UserName,
		EName,
		Description,
		BillNumber,
		CompanyId,
		CompanyIdCur,
		DepartmentIdCur,A_tx
	)
	Values
	(
		@CreateDate,
		@TradeDate,
		@Summary,
		@CateOneId,
		@CateOneName,
		@CateTwoId,
		@CateTwoName,
		@SubjectId,
		@SubjectName,
		@PaymentTypeId,
		@PaymentTypeName,
		@BankId,
		@BankName,
		@OutlayReason,
		@OutlayPrice,
		@Agent,
		@AgentName,
		@PZPerson,
		@PZPersonName,
		@SHPerson,
		@SHPersonName,
		@UserName,
		@EName,
		@Description,
		@BillNumber,
		@CompanyId,
		@CompanyIdCur,
		@DepIdCur,@a_tx
	)
	
	Delete From Finance_Outlay_Temp Where Id=@deleteId
End
	RETURN

